import sys
import pygame
from settings import Settings
from ship import Ship
import game_functions as gf
from pygame.sprite import Group
def run_game():
	#初始化游戏并创建一个屏幕对象
	pygame.init()
	#读取配置文件
	my_settings = Settings()
	screen = pygame.display.set_mode((my_settings.screen_width,my_settings.screen_height))
	pygame.display.set_caption("外星人入侵")
	#创建一艘飞船
	ship = Ship(screen,my_settings)
	#创建一个用于存储子弹的编组
	bullets = Group()
	aliens = Group()
	#创建外星人群
	gf.create_fleet(my_settings,screen,ship,aliens)
	#开始游戏的主循环
	while True:
		#监视键盘和鼠标事件
		gf.check_events(my_settings,screen,ship,bullets)
		ship.update()
		gf.update_bullets(my_settings,screen,ship,aliens,bullets)
		gf.update_aliens(my_settings,aliens)
		#每次循环时都重绘屏幕
		gf.update_screen(my_settings,screen,ship,aliens,bullets)
run_game()
